***
***	INTERTEMPORAL EVIDENCE ON THE STRATEGY OF POPULISM IN THE US (Gennaro, Lecce, Morelli)
***	Replication Package
***  
*** Appendix - Table A13
***
***********************************************************************************************



clear
est clear 

* Indicate location of the replication package here
cd "/Replication Package"

* Presidential
use "3_data/for_analysis/presidential_election_complete.dta", clear


egen mch_s = std(mch)
egen pop_dim2_s = std(pop_dim2)
egen pc1_s = std(pc1)

gen t_m = trump*pc1_s
gen t_m_s = trump*pc1_s*swing
gen t_s = trump*swing
gen m_s = pc1_s*swing
label var trump "Trump"
label var pc1_s "Econ. Ins."
label var t_m "Trump $\times$ Econ. Ins."
label var t_s "Trump $\times$ Swing"
label var t_m_s "Trump $\times$ Econ. Ins. $\times$ Swing"

eststo m1: areg pop_dim2_s trump pc1_s t_m i.mcode length, a(statecode) cluster(MSANAME)
eststo m2: areg pop_dim2_s trump pc1_s swing t_m t_s m_s t_m_s i.mcode length mch_s, a(statecode) cluster(MSANAME)


* Congress
use "3_data/for_analysis/congress_election_2018", clear


gen loglength = log(len_words)
encode age1, gen(age2)
encode ethnicity, gen(ethnicity2)

egen pop_dim2_s = std(pop_dim2)
egen age_s = std(age)
egen pc1_a = std(pc1)

gen o_m = outsider*manu_s
gen o_m_c = outsider*manu_s*competitivedistricts
gen m_c = manu_s*competitivedistricts
gen o_c = outsider*competitivedistricts
gen o_p = outsider*pc1_a
gen o_p_c = outsider*pc1_a*competitivedistricts
gen p_c = pc1_a*competitivedistricts


label var manu_s "Econ. Ins."
label var outsider "Outsider"
label var o_m "Outsider $\times$ Econ. Ins."
label var o_m_c "Outsider $\times$ Econ. Ins. $\times$ Comp."

eststo m3: areg pop_dim2_s pc1_a outsider o_p female i.age2 i.ethnicity2 i.educ2 len_words if uncont==0 & indep==0, a(state) cluster(diststate)

eststo m4: areg pop_dim2_s pc1_a outsider competitive o_p o_c p_c o_p_c manu_s female i.age2 i.ethnicity2 i.educ2 len_words if uncont==0 & indep==0, a(state) cluster(diststate)


esttab m1 m2 m3 m4 using "4_results/tables/tabA5.tex", f label replace booktabs alignment(D{.}{.}{-1}) ///
keep(pc1_s trump t_m t_s m_s t_m_s pc1_a outsider o_p o_c p_c o_p_c competitivedistricts) ///
s(N r2, fmt(0 2) label("Observations" "R-squared")) ///
nomtitles star(* 0.10 ** 0.05 *** 0.01) r2 b(3) se(3) brac nonotes








